package ${basePackage}.controller;

import ${basePackage}.common.Page;
import ${basePackage}.common.Pageable;
import ${basePackage}.common.WebResult;
import ${basePackage}.entity.${table.className};
import ${basePackage}.service.${table.className}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Date  ${date}
 */
@RestController
public class ${table.className}Controller {

    @Autowired
    private ${table.className}Service ${table.objectName}Service;

    @RequestMapping(path = "create${table.className}", method = RequestMethod.POST)
    @ResponseBody
    public WebResult<Void> create(@RequestBody ${table.className} ${table.objectName}) {
        ${table.objectName}Service.create${table.className}(${table.objectName});
        return WebResult.success();
    }

    @RequestMapping(path = "update${table.className}", method = RequestMethod.PUT)
    @ResponseBody
    public WebResult<Void> update${table.className}(@RequestBody ${table.className} ${table.objectName}) {
        ${table.objectName}Service.update${table.className}(${table.objectName});
        return WebResult.success();
    }

    @RequestMapping(path = "delete${table.className}", method = RequestMethod.DELETE)
    @ResponseBody
    public WebResult<Void> delete${table.className}(Long id) {
        ${table.objectName}Service.delete${table.className}(id);
        return WebResult.success();
    }

    @RequestMapping(path = "page${table.className}", method = RequestMethod.POST)
    @ResponseBody
    public WebResult<Page<${table.className}>> page(@RequestBody Pageable pageable) {
        Page<${table.className}> page = ${table.objectName}Service.page${table.className}(pageable);
        return WebResult.success(page);
    }

}
